package com.zlict.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.admin.domain.RdFinanceSubject;
import com.zlict.admin.service.IRdFinanceSubjectService;
import com.zlict.common.utils.poi.ExcelUtil;
import com.zlict.common.core.page.TableDataInfo;

/**
 * 财务管理-科目维护Controller
 * 
 * @author ruoyi
 * @date 2025-06-16
 */
@RestController
@RequestMapping("/system/subject")
public class RdFinanceSubjectController extends BaseController
{
    @Autowired
    private IRdFinanceSubjectService rdFinanceSubjectService;

    /**
     * 查询财务管理-科目维护列表
     */
    //@PreAuthorize("@ss.hasPermi('system:subject:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdFinanceSubject rdFinanceSubject)
    {
        //startPage();
        List<RdFinanceSubject> list = rdFinanceSubjectService.selectRdFinanceSubjectList(rdFinanceSubject);
        return getDataTable(list);
    }

    /**
     * 导出财务管理-科目维护列表
     */
    //@PreAuthorize("@ss.hasPermi('system:subject:export')")
    @Log(title = "财务管理-科目维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RdFinanceSubject rdFinanceSubject)
    {
        List<RdFinanceSubject> list = rdFinanceSubjectService.selectRdFinanceSubjectList(rdFinanceSubject);
        ExcelUtil<RdFinanceSubject> util = new ExcelUtil<RdFinanceSubject>(RdFinanceSubject.class);
        util.exportExcel(response, list, "财务管理-科目维护数据");
    }

    /**
     * 获取财务管理-科目维护详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:subject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rdFinanceSubjectService.selectRdFinanceSubjectById(id));
    }

    /**
     * 新增财务管理-科目维护
     */
    //@PreAuthorize("@ss.hasPermi('system:subject:add')")
    @Log(title = "财务管理-科目维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdFinanceSubject rdFinanceSubject)
    {
        return toAjax(rdFinanceSubjectService.insertRdFinanceSubject(rdFinanceSubject));
    }

    /**
     * 修改财务管理-科目维护
     */
    //@PreAuthorize("@ss.hasPermi('system:subject:edit')")
    @Log(title = "财务管理-科目维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdFinanceSubject rdFinanceSubject)
    {
        return toAjax(rdFinanceSubjectService.updateRdFinanceSubject(rdFinanceSubject));
    }

    /**
     * 删除财务管理-科目维护
     */
    //@PreAuthorize("@ss.hasPermi('system:subject:remove')")
    @Log(title = "财务管理-科目维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdFinanceSubjectService.deleteRdFinanceSubjectByIds(ids));
    }
}
